package com.attendancesystem.service;

import com.attendancesystem.util.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class ChangePasswordService {
    public Boolean changePassword(String username,String password)
    {
        String sql = "UPDATE user SET password = ? WHERE username = ?";
        try(Connection conn = JDBCUtils.getConnection();
            PreparedStatement pstmt = conn.prepareStatement(sql)){
            pstmt.setString(1,password);
            pstmt.setString(2,username);
            if(pstmt.executeUpdate()>0){
                return true;
            }
        }catch (SQLException e){
            e.printStackTrace();
        }
        return false;
    }
}
